<?php
	require_once("obj/user.php");
	require_once("obj/session.php");
	
	if(isset($_POST["txtEmail"])){
		$email = $_POST["txtEmail"];
		$pwd = $_POST["txtPwd"];
		$user = User::get($email, $pwd);
		if($user == null || $user->UserId == null){
			echo "<div class='error'>Invalid username/password</div><br/>";
		}
		else {
			$s = Session::create($user->UserId);
			header("Location:index.php?sid=".$s->SID);
		}
	}
?>

<form method="post" action="index.php">
<table cellpadding="5" cellspacing="0">
	<tr>
		<td>Email:</td>
		<td><input id="txtEmail" name="txtEmail" type="text" value="chrisbzd@windstream.net" /></td>
	</tr>
	<tr>
		<td>Password:</td>
		<td><input id="txtPwd" name="txtPwd" type="password" value="monkey" /></td>
	</tr>
	<tr>
		<td colspan="2"><input id="btnSubmit" type="submit" value="Submit" /></td>		
	</tr>
	<tr>
		<td colspan="2">
			<a href="index.php?page=forgot">I forgot my password</a> | 
			<a href="index.php?page=resetpwd">Change Password</a>
		</td>
	</td>
</table>
</form>